package electricity.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import electricity.domain.EquipmentRepair;
import electricity.domain.FaultAnalysis;
import electricity.dto.DeviceQueryDTO;
import electricity.mapper.FaultAnalysisMapper;
import electricity.service.FaultService;
import electricity.vo.FaultTypeVo;
import electricity.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FaultServiceImpl implements FaultService {
    @Autowired
    private FaultAnalysisMapper faultAnalysisMapper;

    @Override
    public PageResult pageQuery(DeviceQueryDTO deviceQueryDTO) {
        PageHelper.startPage(deviceQueryDTO.getPage(), deviceQueryDTO.getPageSize());
        Page<FaultAnalysis> page = faultAnalysisMapper.pageQuery(deviceQueryDTO);
        return new PageResult(page.getTotal(), page.getResult());
    }

    @Override
    public List<FaultTypeVo> typeDistribution() {
        List<FaultTypeVo> list = faultAnalysisMapper.typeDistribution();
        return list;

    }
}
